package ED;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Tiago Brasileiro
 * 
 * Class that represent a node in a tree of a huffman code.
 * 
 */
public class Node implements Comparable<Node> {
	public Node left;
	public Node right;
	public int frequency;
	public char character;
	public Node parent;
	private boolean isLeaf = false;
	public boolean isLeaf() {
		return isLeaf;
	}

	public void setLeaf(boolean isLeaf) {
		this.isLeaf = isLeaf;
	}

	private List<Integer> posicoes_dos_caracteres = new ArrayList<Integer>();
	
	@Override
	public boolean equals(Object obj) {
		Node other = (Node)obj;
		return this.character == other.character;
	}

	@Override
	public int compareTo(Node other) {
		return this.frequency - other.frequency;
	}
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return String.valueOf(character + " >> " + frequency);
	}
	
	public void adicionaPosicao(Integer p) {
		posicoes_dos_caracteres.add(p);
	}
	
	public List<Integer> getPosicoes() {
		return posicoes_dos_caracteres;
	}
	
}

